#include <iostream>
using namespace std;

int a,B,n;


int dfs(int *k,int w,int *b){
	if(w == B-1) return 0;
	b[w] = 1;
	int min=n+1,l;
	for(int i=0;i<n;i++){
		if(k[w*n+i] && !b[i]){
			l=dfs(k,i,b);
			if(l == -1) continue;
			if(l < min) min = l;
		}
	}
	b[w] = 0;
	if(min != n+1) return min+1;
	return -1;
}


int main(){
	int l;
	cin>>n>>a>>B;
	int k[n][n],b[n]={0};
	for(int i=0;i<n;i++){
		cin>>l;
		for(int j=0;j<n;j++) k[i][j]=0;
		if(i-l >= 0) k[i][i-l] = 1;
		if(i+l < n) k[i][i+l] = 1;
	}
	if(a == B){
		cout<<0;
		return 0;
	}
	l = dfs(&k[0][0],a-1,b);
	cout<<l;
	return 0;
}
